home *** CD-ROM | disk | FTP | other *** search
- /*
- * This code illustrates how to create growth and magnitude statistic nodes
- * and how to update their values.
- */
-
- #include "Instrumentation.h"
-
-
- OSStatus InitInstrumentation( void);
- void UpdateStatistics( UInt32 monthsElapsed, SInt32 profit);
-
- InstGrowthClassRef gMonthsStat;
- InstMagnitudeClassRef gCashStat;
-
-
- void main()
- {
- OSStatus err;
-
- if ( noErr == ( err = InitInstrumentation()))
- {
- UpdateStatistics( 6, 120); // hummin' along
- UpdateStatistics( 3, -760); // oops, bad quarter
- UpdateStatistics( 3, -32); // the recovery...
- }
- }
-
-
- OSStatus InitInstrumentation( void)
- /* Create and enable our statistics nodes. They are initially zero. */
- {
- OSStatus err;
-
- err = InstCreateGrowthClass( kInstRootClassRef, "Samples:Months Past",
- kInstEnableClassMask, &gMonthsStat);
-
- if ( noErr == err)
- err = InstCreateMagnitudeClass( kInstRootClassRef, "Samples:Revenue",
- kInstEnableClassMask, &gCashStat);
- return err;
- }
-
-
- void UpdateStatistics( UInt32 monthsElapsed, SInt32 profit)
- /* Update the statistics with some new values. */
- {
- // update the number of months that have gone by
- InstUpdateGrowth( gMonthsStat, monthsElapsed);
-
- // update the cash total with the new delta
- InstUpdateMagnitudeDelta( gCashStat, profit);
- }
-
-
-